import request from "@/utils/request.js";

export function listStudentAbsence(query) {
    return request({
        url: '/leave/student/view',
        method: 'post',
        data: query.data,
        params: {
            current: query.current,
            size: query.size
        }
    })
}

export function listAdminAbsence(query) {
    return request({
        url: '/leave/request',
        method: 'post',
        data: query.data,
        params: {
            current: query.current,
            size: query.size
        }
    })
}

// admin审核申请
export function approveApply0(bool,applicationIds) {

    return request({
        url: '/leave/change',
        method: 'post',
        params: {
            isApproved: bool,
        },
        data: {
            applicationId: applicationIds,
        },
        headers: {
            'Content-Type': 'application/json'
        }

    })
}

//admin销假
export function approveAbsBack(bool,applicationIds) {

    return request({
        url: '/leave/approve',
        method: 'post',
        params: {
            isApproved: bool,
        },
        data: {
            applicationId: applicationIds,
        },
        headers: {
            'Content-Type': 'application/json'
        }

    })
}

// 学生发送申请
export function postAbsApply(formData) {
    return request({
        url: '/leave/student/apply',
        method: 'post',
        data: formData,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

// 学生修改申请
export function changeAbsApply(formData,applicationId) {
    return request({
        url: '/leave/student/update',
        method: 'post',
        data: formData,
        params: {
            applicationId: applicationId
        },
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

// 学生撤回申请
export function deleteAbsApply(applicationId) {
    return request({
        url: '/leave/student/delete',
        method: 'post',
        params: {
            applicationId: applicationId
        },

    })
}

// 学生申请销假
export function postAbsBack(applicationId) {
    return request({
        url: '/leave/student/back',
        method: 'post',
        params: {
            applicationId: applicationId
        }
    })
}